var express = require('express');
var router = express.Router();
var UserModel = require('../models/user');
var checkLogin = require('../middlewares/check').checkLogin;


router.post('/',function(req, res, next){
    
    let body = req.body;
    let page = body.page;
    let pageSize = body.pageSize;
    
    UserModel.findUsers(page,pageSize)
             .then((users)=>{
                 //获取总条数
                UserModel.findAll()
                         .then((result)=>{
                             res.json({
                                 code:1,
                                 data:users,
                                 count: result.length
                             })
                         }).catch((err)=>{
                             res.send(err);
                         })
             }).catch((err)=>{
                res.send(err);
             });
    
});



module.exports = router;